<template>
	<div class="comment" v-if="pageResult.list.length > 0">
	<SRV-topbar  title="小黄人急救：全部评论"></SRV-topbar>
		<div class="item" v-for="(item, index) in pageResult.list" :key="index">
			<div class="member">
				<SRV-profile :potos="item.member_head_portrait" :topicon="item.topicon" :srvhour="item.total_time" size="70"></SRV-profile>
				<div class="info">
					<p>
						<label>{{item.member_nickname}}</label>
						<span>{{item.scores_name}}</span>
					</p>
					<p>{{item.create_time}}</p>
				</div>
			</div>
			<div class="inner">{{item.content}}</div>
		</div>
	</div>
	<view class="nocomment" v-else>
		暂无评价～
	</view>
</template>

<script>
	import serve from '../../static/request.js';
	import storage from '../../static/appkey.js';
	import common from '../../static/jump.js';
	export default {
		data() {
			return {
				pageParam: {
					appkey: uni.getStorageSync('appkey'),
					'access-token': uni.getStorageSync('access-token'),
					product_id: 0,
					page: 0,
				},
				pageResult: {
					list: [],
					isEmpty: false,
					isEnd: false
				}
			}
		},
		methods: {
			getStat() {
				var self = this;
				serve
					.request({
						url: '/product/evaluate-stat/view',
						data: {
							appkey: uni.getStorageSync('appkey'),
							'access-token': uni.getStorageSync('access-token'),
							id: self.pageParam.product_id,
						}
					})
					.then(res => {
						console.log(res.data); 
						
					});
			},
			getList(){
				var self = this;
				self.pageParam.page++
				serve
					.request({
						url: '/product/evaluate/index',
						data: self.pageParam
					})
					.then(res => {
						console.log(res.data); 
						if (res.data && res.data.length > 0) {
							self.pageResult.list=self.pageResult.list.concat(res.data);
						}
						self.pageResult.isEmpty = self.pageResult.list.length == 0;
						self.pageResult.isEnd = res.data.length == 0; 
					});
			},
			jump(jump_type, jump_link){
				common.jump(jump_type, jump_link);
			}
		},
		onLoad(options) {
			this.pageParam.product_id = options.id || 0;
			if(this.pageParam.product_id == 0) {
				uni.showToast({
					title: "错误的访问方式",
					icon: 'none',
					success() {
						setTimeout(function () {
							this.jump('product_list')
						}, 2000) 
					}
				});
			}
			this.getList();
		},
		onPullDownRefresh() {
			self.pageParam.page=0;
			self.pageResult.list=[];
			this.getList();
		},
		onReachBottom() {
			if(this.pageResult.isEnd ||this.pageResult.isEmpty){
				return
			}
			this.getList()
		}
	}
</script>
<style lang="scss">
.comment {
	padding-left: 30rpx;
	.item {
		border-bottom: 1rpx solid rgba(57,72,107,0.08);
		.member {
			padding: 48rpx 0 35rpx;
			display: flex;
			align-items: center;

		

			.info {
				flex: 1;
				padding-right: 30rpx;
				p {
					font-size: 20rpx;
					font-family: Microsoft YaHei UI;
					font-weight: 400;
					color: rgba(60, 72, 104, 1);
					opacity: 0.5;

					&:nth-child(1) {
						font-size: 28rpx;
						font-family: Microsoft YaHei UI;
						font-weight: bold;
						color: rgba(60, 72, 104, 1);
						display: flex;
						align-items: center;
						justify-content: space-between;
						opacity: 1;
						width: 100%;

						span {
							font-size: 24rpx;
							font-family: Microsoft YaHei UI;
							font-weight: 400;
							color: rgba(235, 89, 56, 1);
						}
					}
				}
			}
		}
		.inner { 
			font-size: 28rpx;
			font-family: Microsoft YaHei UI;
			font-weight: 400;
			color: rgba(60, 72, 104, 1); 
			padding: 0 30rpx 48rpx 76rpx;
		}
	}
}
.nocomment {
	font-size: 28upx;
	color: rgba(60, 72, 104, 0.5);
	width: 100%;
	padding: 87upx 0upx;
	text-align: center;
}
</style>
